#!/usr/bin/env python
# __author__ = "lynn.lin <lynnos@tong-ji.org>"
# __date__ = "2008-09-20"


#====================
# netmask->prefix len
# 255.255.252.0 -> 22
# 255.255.255.0 -> 24
#===================

import decimal2binary
import sys

def convert(netmask):
	netbit = netmask.split('.')
	if len(netbit) != 4 :
		return -1
	length = len(netbit)
	prelen = 0;
	for i in xrange(length):
		binary = decimal2binary.decimal2binary(int(netbit[i]))
		prelen += binary.count(1)

	return prelen

if __name__ == '__main__':
	netmask = sys.argv[1]
	res = convert(netmask)
	print res

			
	



